﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.OleDb;
using System.Data;
using DTO;

namespace DAO
{
    public class KhachHangDAO : AbstractDAO
    {
        public List<KhachHangDTO> GetAll()
        {
            OleDbConnection connection = Open();
            string sql = "SELECT * FROM KhachHang";
            OleDbCommand command = new OleDbCommand(sql, connection);
            OleDbDataReader reader = command.ExecuteReader();
            List<KhachHangDTO> dsKhachHang = new List<KhachHangDTO>();
            KhachHangDTO s;
            while (reader.Read())
            {
                s = new KhachHangDTO();
                s.MaKhachHang = reader.GetInt32(0);
                s.HoTenKhachHang = reader.GetString(1);
                s.NoHienTai = reader.GetDouble(2);
                s.DiaChi = reader.GetString(3);
                s.DienThoai = reader.GetInt32(4);
                s.Email = reader.GetString(5);
                s.TinhTrang = reader.GetBoolean(6);
                dsKhachHang.Add(s);
            }
            Close(connection);
            return dsKhachHang;
        }
    }
}
